package com.hfzy.ihk.facade.calldata.enums;

import com.hfzy.ihk.common.facade.elasticsearch.ElasticsearchVersionRedisKey;
import com.hfzy.ihk.common.facade.elasticsearch.entity.ElasticsearchTable;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2018/8/15.
 */
public enum CallDataRedisVersionKey implements ElasticsearchVersionRedisKey {
    /**
     * 控制字段基础字段
     * */
    TABLE_CALL_HISTORY("call_history_version","呼叫记录",CallDataTables.CALL_HISTORY),
    TABLE_CALL_HISTORY_TEXT("call_history_text_Version","通话内容",CallDataTables.CALL_HISTORY_TEXT),
    TABLE_CALL_TASK_DETAIL("call_task_detail_version","呼叫任务详情",CallDataTables.CALL_TASK_DETAIL)
    ;

    private CallDataRedisVersionKey(String value, String desc, ElasticsearchTable belongTable){
        this.value = value;
        this.desc = desc;
        this.belongTable = belongTable;
    }

    private String value;

    private String desc;

    private ElasticsearchTable belongTable;

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String getVersionKeyName() {
        return belongTable.getTableName()+":"+value;
    }

    private static Map<String, CallDataRedisVersionKey> map = new HashMap<String, CallDataRedisVersionKey>();
    static {
        for (CallDataRedisVersionKey value : CallDataRedisVersionKey.values()) {
            map.put(value.getValue(), value);
        }
    }

    public static CallDataRedisVersionKey fromValue(String value) {
        CallDataRedisVersionKey ret = map.get(value);
        if (ret != null) {
            return ret;
        } else {
            throw new IllegalArgumentException("No enum const " + CallDataRedisVersionKey.class + "." + value);
        }
    }
}
